package com.hziee.cosmanage.search.controller;

import com.hziee.common.utils.R;
import com.hziee.cosmanage.search.service.ElasticInviteService;
import com.hziee.cosmanage.search.vo.InviteVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RequestMapping("search")
@RestController
@Slf4j
public class ElasticController {

    @Autowired
    ElasticInviteService elasticInviteService;

    //招聘信息上传
    @PostMapping("/saveInvite")
    public R inviteStatusUp(@RequestBody List<InviteVo> vos) throws IOException {
        boolean b = elasticInviteService.inviteStatusUp(vos);
        if (!b) {
            return R.ok();
        } else {
            return R.error("失败");
        }
    }

    /**
     * 招聘信息跟新
     * @return
     */
    @PostMapping("/updateInvite")
    public R updateESInvite(@RequestBody InviteVo vo){
        boolean b = elasticInviteService.updateESInvite(vo);
        return R.ok();
    }
}
